Skip to main content

All Questions

Tagged with
2votes
1answer
81views

Calculating array segment uniformity using a segment tree

You have to analyze some array of \$n\$ numbers. In particular, you are interested in the so-called array uniformity. Suppose that in the array the number \$b_1\$ appears \$k_1\$ times, \$b_2\$ \$k_2\$...
Dmitry's user avatar
2votes
2answers
104views

Minimum length of specific substrings

Given the string \$s\$. It is required to answer n queries. The \$i\$th query consists of an integer \$k_i\$ and a string \$m_i\$, the answer is the minimum length of the string \$t\$ such that \$t\$ ...
Dmitry's user avatar
6votes
3answers
212views

Find the number of cycles of length 3

Given the count. Find the number of cycles of length 3. Input format: The first line contains two integers n and m (1 < n, m ≤ 3✕10⁵) — the number of vertices and edges, respectively. Each of the ...
Dmitry's user avatar
4votes
2answers
2kviews

Fast OrderBook Implementation

I'm creating a simple yet fast OrderBook, that only adds orders and matches them (no cancelling or modifications, etc.). I'm using partial template specialization to reduce branching in the hotpath, ...
jpf's user avatar
  • 63
5votes
5answers
976views

Palindrome Permutation string

I’m starting to learn C++ by doing a lot of exercises, and I need your help so I can improve, Here is how it goes, I will try to solve an exercise and post both the ...
April Morrison's user avatar
1vote
1answer
283views

Storing different types with common base using atomic-based typeid

I'm trying to develop some kind of in-memory store for my entities. These entities are representations of the devices available on the system. There may be eg. 3 leds, 1 temp sensor, 2 engines etc. ...
bielu000's user avatar
3votes
1answer
4kviews

C++ callback multithreaded, can unregister itself

update: a new version of this code is posted here With this post, i would like to 1) ask for feedback on below code as it stands: do i apply all best practices for c++20? is it safe? is my way to ...
Diederick C. Niehorster's user avatar
4votes
1answer
722views

Template Metaprogramming - Multidimensional Vector Declaration

[EDIT] The question has been edited. Please make sure to read the summary at the end of the post. If you'd like me to make a new post with a cleaner explanation and better examples, tell me to do so ...
Arrow's user avatar
4votes
1answer
247views

Is there a better solution to get RTTI info about a polymorphic type?

I made some code to get RTTI information of a polymorphic object, it works both if you pass it directly or a pointer to it(the pointer will get dereferenced until null or the object is found), it's ...
Mirko Angel's user avatar
12votes
1answer
5kviews

C++17 <span> implementation

C++20 added the span library under the header <span>. As voluntary exercise (not homework!), I spent approximately 1.5 ...
L. F.'s user avatar
  • 9,625

close